﻿#region Copyright 2008 - Evolution Systems.
//
// Author: José Rogério Ferreira dos Santos(joserogerio.santos@gmail.com)
// Date: 28/12/2008
// Time: 11:24
// All rights are reserved. Reproduction or transmission in whole or in part, in
// any form or by any means, eletronic, mechanical or otherwise, is prohibited
// without the prior written permission of the author.
//
// Filename: ${FILE_NAME}.cs
#endregion
using System;
using ComponentFactory.Krypton.Toolkit;

namespace csharp.rad.general
{
	/// <summary>
	/// Description of Functions.
	/// </summary>
	public class Functions
	{
		public static void fillComboCountries(Countries list, KryptonComboBox cmb, String valueMember, String diplayMember)
		{
			cmb.Items.Clear();
			for(int i=0; i < list.count(); i++)
				cmb.Items.Add(list.get(i));
			cmb.ValueMember= valueMember;
			cmb.DisplayMember = diplayMember;
		}
		
		public static void fillComboStates(States list, KryptonComboBox cmb, String valueMember, String diplayMember)
		{
			cmb.Items.Clear();
			for(int i=0; i < list.count(); i++)
				cmb.Items.Add(list.get(i));
			cmb.ValueMember= valueMember;
			cmb.DisplayMember = diplayMember;
		}
		
		public static void fillComboCities(Cities list, KryptonComboBox cmb, String valueMember, String diplayMember)
		{
			cmb.Items.Clear();
			for(int i=0; i < list.count(); i++)
				cmb.Items.Add(list.get(i));
			cmb.ValueMember= valueMember;
			cmb.DisplayMember = diplayMember;
		}	

		public static void fillComboNeighborhoods(Neighborhoods list, KryptonComboBox cmb, String valueMember, String diplayMember)
		{
			cmb.Items.Clear();
			for(int i=0; i < list.count(); i++)
				cmb.Items.Add(list.get(i));
			cmb.ValueMember= valueMember;
			cmb.DisplayMember = diplayMember;
		}			
		
		//Estrutura especial, pois tem a classe pessoa dentro da cliente
		public static void fillComboEmployees(Employees list, KryptonComboBox cmb, String valueMember, String diplayMember)
		{
			cmb.Items.Clear();
			for(int i=0; i < list.count(); i++)
				cmb.Items.Add(new common.structCombo(list.get(i).id, list.get(i).person.name));
			cmb.ValueMember= valueMember;
			cmb.DisplayMember = diplayMember;
		}			
		
		public static void fillComboTypes(Types list, KryptonComboBox cmb, String valueMember, String displayMember)
		{
			cmb.Items.Clear();
			for(int i=0; i < list.count(); i++)
				cmb.Items.Add(list.get(i));
			cmb.ValueMember= valueMember;
			cmb.DisplayMember = displayMember;	
		}
		
		public static void setSelectIndexComboCountries(KryptonComboBox cmb, String value)
		{
			for (int i=0; i < cmb.Items.Count; i++)
				if (value.Equals((cmb.Items[i] as Country).id))
				{
					cmb.SelectedIndex= i;
					break;
				}					
		}		
		
		public static void setSelectIndexComboStates(KryptonComboBox cmb, String value)
		{
			for (int i=0; i < cmb.Items.Count; i++)
				if (value.Equals((cmb.Items[i] as State).id))
				{
					cmb.SelectedIndex= i;
					break;
				}					
		}
		
		public static void setSelectIndexComboCities(KryptonComboBox cmb, String value)
		{
			for (int i=0; i < cmb.Items.Count; i++)
				if (value.Equals((cmb.Items[i] as City).id))
				{
					cmb.SelectedIndex= i;
					break;
				}					
		}		
		
		public static void setSelectIndexComboNeighborhoods(KryptonComboBox cmb, String value)
		{
			for (int i=0; i < cmb.Items.Count; i++)
				if (value.Equals((cmb.Items[i] as Neighborhood).id))
				{
					cmb.SelectedIndex= i;
					break;
				}			
		}		
		
		public static void setSelectedIndexComboTypes(KryptonComboBox cmb, String value)
		{
			for (int i=0; i < cmb.Items.Count; i++)
				if (value.Equals((cmb.Items[i] as TType).id))
				{
					cmb.SelectedIndex= i;
					break;
				}
		}
		
		public static void setSelectedIndexComboEmployes(KryptonComboBox cmb, String value)
		{
			for (int i=0; i < cmb.Items.Count; i++)
				if (value.Equals((cmb.Items[i] as common.structCombo).id))
				{
					cmb.SelectedIndex= i;
					break;
				}
		}		
	}
}
